package com.hdwe.tools.pm.domain.enums;

import lombok.Getter;
import org.dromara.common.core.utils.MarkdownUtil;

/**
 * TODO
 *
 * @author: lus
 * @date: 2025/1/8 15:30
 */
@Getter
public enum TaskStatus {
    NOT_STARTED("未开始", "ready", "🌱", "赶紧开始吧！", ""),
    IN_PROGRESS("进行中", "doing", "🏃‍♂️", "加油鸭！", ""),
    FINISHED("已完成", "finished", "🏆", "恭喜恭喜！", ""),
    CANCELLED("取消", "cancel", "❌", "记录原因！", ""),
    BLOCKED("阻塞", "blocked", "🚧", "啥原因？赶紧描述清楚，反馈，盯紧点！", ""),
    DELAYED("延期", "delay", "⏰", "遇到什么问题了么？赶紧向上反馈吧！", ""),
    TESTING("测试中", "testing", "🔍", "测试用例全面些，别漏了！", ""),
    DEPLOYED("已上线", "deployed", "🚀", "上线啦，赶紧让用户体验！", "");

    private final String desc;
    private final String code;
    private final String icon;
    private final String comment;
    private final String action;

    TaskStatus(String desc, String code, String icon, String comment, String action) {
        this.desc = desc;
        this.code = code;
        this.icon = icon;
        this.comment = comment;
        this.action = action;
    }

    public static String icon(String code) {
        for (TaskStatus taskStatus : TaskStatus.values()) {
            if (taskStatus.getCode().equals(code)) {
                return taskStatus.getIcon();
            }
        }
        throw new IllegalArgumentException("Unknown TaskStatus: " + code);
    }
    public static String desc(String code) {
        for (TaskStatus taskStatus : TaskStatus.values()) {
            if (taskStatus.getCode().equals(code)) {
                return taskStatus.getDesc();
            }
        }
        throw new IllegalArgumentException("Unknown TaskStatus: " + code);
    }
    public static String comment(String code) {
        for (TaskStatus taskStatus : TaskStatus.values()) {
            if (taskStatus.getCode().equals(code)) {
                return taskStatus.getComment();
            }
        }
        throw new IllegalArgumentException("Unknown TaskStatus: " + code);
    }

    public static String markdown(String code) {
        String color = switch (code) {
            case "blocked", "delay" -> "warning";
            case "finished" -> "info";
            default -> "comment";
        };
        return MarkdownUtil.createFont(desc(code), color);
    }

    public boolean eq(String status) {
        return this.code.equals(status);
    }

    public boolean ne(String status) {
        return !this.code.equals(status);
    }
}
